package com.me.study.javaBasic.shell;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * Java 执行 命令行
 *
 * @author ME
 * @date 2021/8/17
 */
public class RunShell {

    public static void main(String[] args) {
        try {
            String shPath = "curl cip.cc";
            Process ps = Runtime.getRuntime().exec(shPath);
            ps.waitFor();

            BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));
            StringBuilder sb = new StringBuilder();
            String line;
            while ((line = br.readLine()) != null) {
                sb.append(line).append("\n");
            }
            String result = sb.toString();
            System.out.println(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
